package com.itheima.order.controller;

import com.itheima.order.entity.Order;
import com.itheima.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @GetMapping("/query")
    public ResponseEntity<List<Order>> findOrderByUsername(@RequestParam("username") String username){
        List<Order> orders= orderService.findOrderByUsername(username);

        return ResponseEntity.ok(orders);
    }

}
